﻿Imports System.Data.OleDb
Imports System.Data
Imports System.Xml
Imports System.Xml.Linq

Public Class RSS
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim cn As OleDbConnection
        Dim app_path As String
        Dim xtxtwrt As XmlTextWriter
        Dim cmd As OleDbCommand
        Dim dr As OleDbDataReader
        app_path = System.AppDomain.CurrentDomain.BaseDirectory()
        cn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & app_path & "\\App_Data\\CAMC_DB.accdb;Persist Security Info=True")
        xtxtwrt = New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
        xtxtwrt.WriteStartDocument()
        xtxtwrt.WriteStartElement("rss")
        xtxtwrt.WriteStartAttribute("version", "2.0")
        xtxtwrt.WriteStartElement("channel")
        xtxtwrt.WriteElementString("title", "Rss Feed American Muscle Cars")
        cn.Open()
        cmd = New OleDbCommand("select * from Vehicle_Overview", cn)
        dr = cmd.ExecuteReader()
        While dr.Read()
            xtxtwrt.WriteStartElement("item")
            xtxtwrt.WriteElementString("title", dr("Vehicle_Name").ToString())
            xtxtwrt.WriteElementString("description", dr("Vehicle_Name").ToString())
            xtxtwrt.WriteElementString("link", "http://localhost:2159/Car_Details.aspx?id=" & dr("ID").ToString())
            xtxtwrt.WriteEndElement()

        End While
        xtxtwrt.WriteEndElement()
        xtxtwrt.WriteEndElement()
        xtxtwrt.WriteEndDocument()
        xtxtwrt.Flush()
        cn.Close()
        Response.End()
    End Sub

End Class